<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <h2>事件处理</h2>
      <!-- 事件处理函数后面的括号可加可不加 -->
      <button v-on:click="handleClick()">btn</button>
      <button @click="handleClick()">btn</button>

      <hr />

      <h2>获取event参数</h2>
      <!-- 默认情况下，加了括号就不能得到event参数 -->
      <!-- 如果既要传递传参，又要拿到event，可以主动传入$event -->
      <!-- <button @click="getEvent">获取event参数</button> -->
      <button @click="getEvent(12222, $event)">获取event参数</button>

      <hr />

      <h2>事件的传参</h2>
      <!-- 加的时候可以用来传递参数 -->
      <button @click="getArg(1)">事件传参1</button>
      <button @click="getArg(2)">事件传参2</button>
    </div>

    <script src="./lib/Vue3.js"></script>
    <script>
      const { createApp } = Vue;

      createApp({
        data() {
          return {};
        },
        methods: {
          handleClick() {
            console.log(123);
          },
          getEvent(n, e) {
            console.log(e);
            console.log(n);
          },
          getArg(num) {
            console.log(num);
          },
        },
      }).mount("#app");
    </script>
  </body>
</html>
